﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebUI.BL.News;

namespace WebUI.UserControls
{
    public partial class UcNameDescription : System.Web.UI.UserControl
    {
        public string Lang { get; set; }
        public string IdNewsCategory { get; set; }

        public string ValidationGroup
        {
            get { return rqfName.ValidationGroup; }
            set { rqfName.ValidationGroup = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                if(!String.IsNullOrEmpty(IdNewsCategory))
                {
                    BindingModelEn();
                }
            }
        }

        private void BindingModelEn()
        {
            var repository = new NewsCategoryBL();
            var storeLang = repository.GetStoreLangugageAttributes(int.Parse(Lang), int.Parse(IdNewsCategory));
            if(storeLang.Any())
            {
                txtName.Text = storeLang.Where(x => x.Attrribute == "Name").Select(n => n.ValueAttr).FirstOrDefault();
                ckey1.Text = storeLang.Where(x => x.Attrribute == "Description").Select(n => n.ValueAttr).FirstOrDefault();
            }
        }
    }
}